"""
@project: PyCharm
@author: MZM
@file: conftest.py
@ide: PyCharm
@time: 2021/6/30 15:06
@desc： 
"""
import logging
import os
import socket

import pytest

from reader import Reader
filepath = os.path.dirname(__file__)
ip = socket.gethostbyname(socket.gethostname())
par_file=filepath + f'/data/test.yaml'

def pytest_collection_modifyitems(items):
    """
    测试用例收集完成时，将收集到的item的name和nodeid的中文显示在控制台上
    :return:
    """
    for item in items:
        item.name = item.name.encode("utf-8").decode("unicode_escape")
        print(item.nodeid)
        item._nodeid = item.nodeid.encode("utf-8").decode("unicode_escape")

@pytest.fixture(params=Reader.read_case(par_file),ids=Reader.read_ids(par_file))
def testdata(request):
    '''
    根据文件的测试用例列表依次返回单条测试用例传给pytest脚本
    :param request:
    :return:
    '''
    # 根据输入参数化的内容获取历史请求、响应中对应模块的参数值
    return request.param
